﻿<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
		<!-- Google Chrome Frame也可以让IE用上Chrome的引擎: -->
		<meta name="renderer" content="webkit">
		<!--国产浏览器高速模式-->
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="author" content="穷在闹市" />
		<!-- 作者 -->
		<meta name="revised" content="穷在闹市.v3, 2019/05/01" />
		<!-- 定义页面的最新版本 -->
		<meta name="description" content="网站简介" />
		<!-- 网站简介 -->
		<meta name="keywords" content="搜索关键字，以半角英文逗号隔开" />


		<!-- 公共样式 开始 -->
		<link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link rel="stylesheet" type="text/css" href="../../css/iconfont.css">
		<script type="text/javascript" src="../../framework/jquery-1.11.3.min.js"></script>
		<link rel="stylesheet" type="text/css" href="../../layui/css/layui.css">
		<script type="text/javascript" src="../../layui/layui.js"></script>
		<!-- 滚动条插件 -->
		<link rel="stylesheet" type="text/css" href="../../css/jquery.mCustomScrollbar.css">
		<script src="../../framework/jquery-ui-1.10.4.min.js"></script>
		<script src="../../framework/jquery.mousewheel.min.js"></script>
		<script src="../../framework/jquery.mCustomScrollbar.min.js"></script>
		<script src="../../framework/cframe.js"></script><!-- 仅供所有子页面使用 -->
		<!-- 公共样式 结束 -->

	</head>

	<body>
		<div class="cBody">
			<div class="console">
				<form class="layui-form" action="">

					<div class="layui-form-item">
						<div class="layui-input-inline">
							<input ID="adminId" type="text" name="name" required lay-verify="required" placeholder="输入分管Id" autocomplete="off" class="layui-input">
						</div>
						<button class="layui-btn" lay-submit lay-filter="formDemo" id="cxBtnbyId">检索</button>
					</div>
				</form>
				<form>
					<div class="layui-form-item">
						<div class="layui-input-inline">
							<input id="Responsible" type="text" name="name" required lay-verify="required" placeholder="输入分管负责地区" autocomplete="off" class="layui-input">
					</div>
						<button class="layui-btn" lay-submit lay-filter="formDemo" id="cxBtnbyResponsible">检索</button>
					</div>
				</form>
				<form>
					<div class="layui-form-item">
						<div class="layui-input-inline">
							<input id="Type" type="text" name="name" required lay-verify="required" placeholder="输入分管类型" autocomplete="off" class="layui-input">
						</div>
						<button class="layui-btn" lay-submit lay-filter="formDemo" id="cxBtnbyType ">检索</button>
					</div>

				</form>

				<script>
                    layui.use('form', function() {
                        var form = layui.form;

                        //监听提交
                        form.on('submit(formDemo)', function(data) {
                            layer.msg(JSON.stringify(data.field));
                            return false;
                        });
                    });
				</script>
			</div>

				<table class="layui-table">
					<thead>
					<tr>
						<td>编号</td>
						<td>用户名</td>
						<td>联系方式</td>
						<td>邮箱</td>
						<td>用户类型</td>
						<td>负责区域</td>
						<td>操作</td>
					</tr>
			</thead>

					<tbody>
					</tbody>
				</table>
			
			<!-- layUI 分页模块 -->
			<div id="pages"></div>
			<script>


                //查询所有
                $.getJSON("/admin/findAllAdmin.json",function(list){
                    $("tbody").empty();
                    for(var i=0;i<list.length; i++){
                        var admin = list[i];
                        var str = "<tr>" +
                            "            <td>"+admin.adminId+"</td>" +
                            "            <td>"+admin.loginName+"</td>" +
                            "            <td>"+admin.mobilePhone+"</td>" +
                            "            <td>"+admin.adminEmail+"</td>" +
                            "            <td>"+admin.typeName+"</td>" +
                            "            <td>"+admin.responsible+"</td>"+
                            "<td><button class='layui-btn layui-btn-xs'>基本信息</button></td>" +
                            "        </tr>";
                        $("tbody").append(str);
                    }
                });


            //根据ID查询具体信息
                $("#cxBtnbyId").click(function () {
                    var adminId = $("#adminId").val();
                    $.getJSON("/admin/findByadminId.json","adminId="+adminId,function(list){
                        $("tbody").empty();
                        for(var i=0;i<list.length; i++){
                            var admin1 = list[i];
                            var str = "<tr>\n" +
                                "            <td>"+admin1.adminId+"</td>\n" +
                                "            <td>"+admin1.loginName+"</td>\n" +
                                "            <td>"+admin1.mobilePhone+"</td>\n" +
                                "            <td>"+admin1.adminEmail+"</td>\n" +
                                "            <td>"+admin1.typeName+"</td>\n" +
                                "            <td>"+admin1.responsible+"</td>\n" +
                                "<button class='layui-btn layui-btn-xs'>基本信息</button></td>" +
                                "        </tr>";
                            $("tbody").append(str);
                        }
                    })
                });


                //根据负责地区查询
                $("#cxBtnbyResponsible").click(function () {
                    var Responsible = $("#Responsible").val();
                    $.getJSON("/admin/findByResponsible.json","Responsible="+Responsible,function(list){
                        $("tbody").empty();
                        for(var i=0;i<list.length; i++){
                            var admin2 = list[i];
                            var str = "<tr>\n" +
                                "            <td>"+admin2.adminId+"</td>\n" +
                                "            <td>"+admin2.loginName+"</td>\n" +
                                "            <td>"+admin2.mobilePhone+"</td>\n" +
                                "            <td>"+admin2.adminEmail+"</td>\n" +
                                "            <td>"+admin2.typeName+"</td>\n" +
                                "            <td>"+admin2.responsible+"</td>\n" +
                                "<button class='layui-btn layui-btn-xs'>基本信息</button></td>" +
                                "        </tr>";
                            $("tbody").append(str);
                        }
                    })
                });



                //根据职务查询

                $("#cxBtnbyType").click(function () {
                    var TypeName = $("#Type").val();
                    $.getJSON("/admin/findByTypee.json","TypeName="+TypeName,function(list){
                        $("tbody").empty();
                        for(var i=0;i<list.length; i++){
                            var admin3 = list[i];
                            var str = "<tr>\n" +
                                "            <td>"+admin3.adminId+"</td>\n" +
                                "            <td>"+admin3.loginName+"</td>\n" +
                                "            <td>"+admin3.mobilePhone+"</td>\n" +
                                "            <td>"+admin3.adminEmail+"</td>\n" +
                                "            <td>"+admin3.typeName+"</td>\n" +
                                "            <td>"+admin3.responsible+"</td>\n" +
                                "<button class='layui-btn layui-btn-xs'>基本信息</button></td>" +
                                "        </tr>";
                            $("tbody").append(str);
                        }
                    })
                });


                $('[name="backBtn"]').click(function () {
                    $.getJSON("/admin/findAllAdmin.json",function(list){
                        $("tbody").empty();
                        for(var i=0;i<list.length; i++){
                            var admin = list[i];
                            var str = "<tr>" +
                                "            <td>"+admin.adminId+"</td>" +
                                "            <td>"+admin.loginName+"</td>" +
                                "            <td>"+admin.mobilePhone+"</td>" +
                                "            <td>"+admin.adminEmail+"</td>" +
                                "            <td>"+admin.typeName+"</td>" +
                                "            <td>"+admin.responsible+"</td>"+
                                "<td><button class='layui-btn layui-btn-xs'>基本信息</button></td>" +
                                "        </tr>";
                            $("tbody").append(str);
                        }
                    });
                })


              //分页
				layui.use(['laypage', 'layer'], function() {
					var laypage = layui.laypage,
						layer = layui.layer;
				
					//总页数大于页码总数
					laypage.render({
					    elem: 'pages'
					    ,count: 'count'
					    ,layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
					    ,jump: function(obj){
					      console.log(obj)
					    }
					});
				});
			</script>
		</div>
	</body>

</html>